# -*- coding:utf-8 -*- 
__date__ = '2022/2/8 7:25 下午'

from util.list_util import random_list


# 一个序列根据基准（一般为下标为0的开始）分成两个序列
def quick_sort(collection):
  if len(collection) <= 1:
    return collection
  base = collection[0]
  left, right = [x for x in collection[1:] if x < base], [x for x in collection[1:] if x >= base]
  return quick_sort(left) + [base] + quick_sort(right)


if __name__ == '__main__':
  ls = random_list()
  res = quick_sort(ls)
  print(ls, res, res == sorted(ls))
